package br.com.javatar.radio.service;

import java.io.File;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import br.com.javatar.client.Client;
import br.com.javatar.entity.Musica;


@Path("/Service")
public class Service {

	@GET
	@Path("/Now")
	@Produces(MediaType.APPLICATION_JSON)
	public List<Musica> buscarMusicaTocada(){
		try {
			return Client.buscarMusicaTocada();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
	@GET
	@Path("/Dow")
	@Produces(MediaType.MULTIPART_FORM_DATA)
	public File buscarMusicaTocada(@QueryParam("id") String id){
		try {
			return Client.baixarMusica(new Musica(id));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	
}
